<?php

/**
 * Created by PhpStorm.
 * User: d7
 * Date: 2016/1/5
 * Time: 16:24
 */
class Article extends MY_Pc_Controller
{
    function __construct()
    {
        parent::__construct();
    }

    function gets(){
        $page = $this->input->get('page');
        $page = $page > 0? $page: 1;
        $conditions=array();
        $conditions['is_del'] = 0;
        if($this->input->get('name')){
            $conditions['name'] = $this->input->get('name');
        }else{
            $this->assign('name', "");
        }
        $base_url = url_query($conditions, '/article/index');

        $pagination = $this->Article_model->pagination($base_url, $page, $conditions, 'id desc');
        $this->session->set_userdata(
            'back_list_page',
            $this->get_self_url()
        );

        $this->assign('pagination', $pagination);
        $this->display();
    }

    function detail($article_id){
        if($article_id<1){
            $this->show_message('id错误',404,site_url());
        }
        $article = $this->Article_model->getOne(array('id'=>$article_id,'is_del'=>0));
        if(!$article){
            $this->show_message('找不到内容',404,site_url());
        }
        $this->assign('article',$article);
        $this->display();
    }
}